import 'package:inmotion_pro/l10n/local.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

enum WebViewUrlType {
  userAgreement, // 用户协议
  privacyPolicy, // 隐私政策
  eucPitchAngleCalibrateFaq, // 独轮 - 平衡角度校正指南
  eucTiltForwardWhenTurningCalibrateFaq; // 独轮 - 转弯前倾校正指南

  String get url {
    switch (this) {
      case userAgreement:
        return 'https://page-us.imscv.net/policies/privacy';
      case privacyPolicy:
        return 'https://page-us.imscv.net/policies/privacy';
      case eucPitchAngleCalibrateFaq:
        return "https://s.imscv.net/a/BUzBfhnQ";
      case eucTiltForwardWhenTurningCalibrateFaq:
        return "https://s.imscv.net/a/LFmQt632";
    }
  }

  String get title {
    switch (this) {
      case userAgreement:
        return local.user_agreement;
      case privacyPolicy:
        return local.privacy_policy;
      case eucPitchAngleCalibrateFaq:
        return local.balance_calibration;
      case eucTiltForwardWhenTurningCalibrateFaq:
        return local.turning_calibration;
    }
  }
}

mixin WebViewMixin {
  void webViewMixinPushTo(WebViewUrlType type) {
    // 用户协议
    Navigator.push(
      Get.context!,
      MaterialPageRoute(
        builder: (context) => CustomWebView(
          url: type.url,
          title: type.title,
        ),
      ),
    );
  }
}
